﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using InformationSystem.BLL.Core.Service;
using System.Data;
using System.Text.RegularExpressions;

namespace InformationSystem.WebSite.Module.NoticeMgr
{
    public partial class Contact : BasePage
    {
        public IUserService UserService { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable dt = UserService.GetUserContact();
            this.ContactStore.DataSource = dt;
            this.ContactStore.DataBind();

            if (Request.QueryString["sto"] != null)
            {
                string[] user = Request.QueryString["sto"].Split(',');

                List<object> data = new List<object>();
                for (var i = 0; i < user.Length; i++)
                {
                    int startindex = user[i].IndexOf('[');
                    int endindex = user[i].IndexOf(']');
                    if (startindex == -1 || endindex == -1) continue;
                    string id = user[i].Substring(startindex+1, endindex - startindex - 1);
                    string name = user[i].Substring(0, startindex);
                    data.Add(new
                    {
                        username = name,
                        userid = id
                    });
                }
                this.SelectedUserStore.DataSource = data;
                this.SelectedUserStore.DataBind();
            }
        }

        protected override bool CommitPermissionCheck()
        {
            throw new NotImplementedException();
        }
    }
}